﻿// =================================================================== 
// Module说明
//====================================================================
// 创建时间：2018-12-10 12:14:26
// 负责人：Sushee
// ===================================================================
using System;
using System.Data;
using System.Collections.Generic;
using System.Linq.Expressions;
using OF.Utility;
using OF.Component.Model;
using OF.Component.IDAL;
using OF.Component.Factory;
namespace OF.Component.BLL
{

    /// <summary>
    /// 扩展
    /// </summary>
    public partial class BaseLocationOperate
    {
        /// <summary>
    	/// 根据断言条件获取单个
    	/// </summary>
        public static BaseLocationInfo QuerySingle(Expression<Func<BaseLocationInfo, bool>> predicate)
        {
            return dal.QuerySingle(predicate);
        }
        /// <summary>
    	/// 根据断言条件获获取列表
    	/// </summary>
        public static IList<BaseLocationInfo> QueryList(Expression<Func<BaseLocationInfo, bool>> predicate)
        {
            return dal.QueryList(predicate);
        }

        /// <summary>
        /// 地理类型的最大ID
        /// </summary>
        /// <param name="locationParentID"></param>
        /// <param name="geographyTypeID"></param>
        /// <returns></returns>
        public static int GetGeographyTypeMaxId(int locationParentID, int geographyTypeID)
        {
            int rid = 0;
            int id = dal.GetGeographyTypeMaxId(locationParentID, geographyTypeID);
            if (id == 0)
            {
                rid = id * 100 + 1;
            }
            else
            {
                rid = id + 1;
            }
            return rid;
        }

        /// <summary>
        /// 省份职级
        /// </summary>
        /// <param name="ddlLocation"></param>
        public static void BindLocation(ref System.Web.UI.WebControls.DropDownList ddlLocation, int Pid)
        {
            IList<BaseLocationInfo> list = QueryList(a => a.LocationID >= 0 && a.LocationParentID == Pid);
            ddlLocation.DataSource = list;
            ddlLocation.DataTextField = "LocationName";
            ddlLocation.DataValueField = "LocationID";
            ddlLocation.DataBind();
        }
    }
}